cmake_minimum_required(VERSION 3.14)

project(conditionalformatting LANGUAGES CXX)
message(${CMAKE_PROJECT_NAME}/${PROJECT_NAME} "项目开始：............................")

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(OS ${CMAKE_SYSTEM_NAME})
set(QT_USE_QSTRINGBUILDER ON)

set(XLSX_INC_DIR ${qt6xlsx_SOURCE_DIR}/include)
set(EXECUTABLE_OUTPUT_PATH ${qt6xlsx_SOURCE_DIR}/bin)    #执行文件生成目录

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Core5Compat)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Core5Compat)

aux_source_directory(. SRC_FILES)
file(GLOB_RECURSE XLSX_FHEADER ${XLSX_INC_DIR}/*.h)
file(GLOB_RECURSE HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h)

add_executable(${PROJECT_NAME}
    ${SRC_FILES}
    ${HEADER_FILES}
    ${XLSX_FHEADER}
)

if(CMAKE_BUILD_TYPE AND (CMAKE_BUILD_TYPE STREQUAL "Debug"))
    set(CMAKE_DEBUG_POSTFIX "_debug")
    message("设置调试输出文件的后缀: " ${CMAKE_DEBUG_POSTFIX})
    set_target_properties(${PROJECT_NAME} PROPERTIES
                          DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
endif()

target_include_directories(${PROJECT_NAME}
                            PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
                            PUBLIC ${qtxlsx_SOURCE_DIR})
target_link_directories(${PROJECT_NAME} PUBLIC ${qt6xlsx_SOURCE_DIR}/lib)

target_link_libraries(${PROJECT_NAME}
    PRIVATE Qt${QT_VERSION_MAJOR}::Core
            Qt${QT_VERSION_MAJOR}::Gui
            Qt${QT_VERSION_MAJOR}::Core5Compat
            qtxlsx
)

message("项目目录：" ${PROJECT_SOURCE_DIR})
message("构造目录：" ${PROJECT_BINARY_DIR})
message("生成目录：" ${EXECUTABLE_OUTPUT_PATH})
message(${EXECUTABLE_OUTPUT_PATH}/${PROJECT_NAME} "项目结束：----------------------------")
message("")
